package 剑指offer;

public interface _05_替换空格 {
    public static void main(String[] args) {
        System.err.println(replaceSpace("We are happy."));
    }

    public static String replaceSpace(String s) {

        //这道题可以使用字符串拼接
        StringBuilder str = new StringBuilder();
        for (char c : s.toCharArray()) {
            str.append(c == ' ' ? "%20" : c);
        }
        return str.toString();

        //这道题当然可以直接引入函数库
        //return s.replace(" ","%20");
    }
}
